#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::H3C::DisplayIpInterfaceBrief < Aio::Module::Cmd::H3C
	include Aio::Module

	def initialize
		super({
			:cmd_full			=> "display ip interface brief",
			:cmd_short		=> "dis ip int b",
			:author				=> "Elin",
			:description	=> "This is H3C Command# display ip interface brief",
			:ranking			=> Ranking_1,
			:platform			=> "all",
		})
	end

	def parse
		context = self.context.dup
		useful[:interface_brief] = {}
		context.readline_match_block(/Interface Physical Protocol IP Address/) {|b|b}
		context.readline_match_block_loop(/(?<interface_id>[^\s]+) (?<status>[^\s]+) (?<protocol>[^\s]+) (?<ip>[^\s]+)/, reg_blank) do |block|
			iface = {}
			iface_id = block[:interface_id]
			useful[:interface_brief][iface_id.to_sym] = iface
			block.update(iface, :interface_id)
			block.update(iface, :ip)
			block.update(iface, :status)
			block.update(iface, :protocol)
		end
	end
end

